at trunk
1 folder
2 files
Reader: extract a read-context module to own the read-route spine
Every read route (author index, publication home, article, RSS)
hand-assembled the same orchestration in its frontmatter: strip the
@ from the URL param, resolve handle -> DID -> PDS, match a
publication by slug, join documents by value.site ===
publication.uri, and map each miss to an error scene. That was ~230
near-duplicate lines across four files, and the join key, the
100-document fetch bound, and the blob-ref -> logo-URL construction
were caller knowledge repeated 3-4x. Living in .astro frontmatter,
none of it was unit-testable - the colocated tests pinned the page
source with regexes instead of behaviour.
resolveAuthorContext / resolvePublicationContext /
resolveArticleContext (src/lib/reader/read-context.ts) now own that
spine behind one interface returning either a fully-shaped context
or ready-made ErrorSceneCopy; the routes keep only presentation.
Publications come back with logoUrl prebuilt so callers never touch
BlobRefJson internals, and the per-route independent fetches
(profile, publication list, documents) run in parallel where the
pages ran them serially.
The module is behaviourally tested in read-context.test.ts (mocking
only the network seam: identity.ts + records.ts); the source-pin
tests shrank to template-wiring guards. The now-unused
listReaderPublications / resolveReaderPublication wrappers are
deleted. Decision 0016 records the seam.
Side effect: RSS 404 bodies are a uniform "Not found" instead of
echoing the handle.